package com.sikaryofficial.gateway.config.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * 接口验签功能参数
 */
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = SignCheckProperties.PREFIX)
@Data
public class SignCheckProperties {
    public static final String PREFIX = "api.gateway.sign-check";
    /**
     * 是否开启功能
     */
    private boolean enable = true;
    /**
     * 允许存在的时间差（单位：秒）
     */
    private Integer timeDiffSeconds = 15;
    /**
     * 密钥
     */
    private List<SecretKey> secretKeys;
    /**
     * 需要签名验证的uri
     */
    private List<String> includeUris;
    /**
     * （includeUris中）需要排除在外的uri
     */
    private List<String> excludeUris;

    @Data
    public static class SecretKey {
        /**
         * clientId
         */
        private String client;
        /**
         * 密钥
         */
        private String secret;
    }
}
